<template>
  <div class="user-time">
    创建人：{{ getUser(0) }}， 创建时间：{{ getTime(0) }}，
    修改人：{{ getUser(1) }}，修改时间：{{ getTime(1) }}
  </div>
</template>

<script>
import CommonUtils from "../utils/CommonUtils.js";

export default {
  name: "UserTime",
  props: {
    param: {
      type: Object
    }
  },
  data() {
    return {
      noData: "无数据",
      paramInner: {}
    }
  },
  methods: {
    getUser(type) {
      if (this.param) {
        if (type === 0) {
          if (this.param.creator) {
            return this.param.creator
          } else {
            return this.noData
          }
        } else {
          if (this.param.updater) {
            return this.param.updater
          } else {
            return this.noData
          }
        }
      } else {
        return this.noData
      }
    },
    getTime(type) {
      if (this.param) {
        if (type === 0) {
          if (this.param.createTime) {
            return CommonUtils.dataToStr(this.param.createTime)
          } else {
            return this.noData
          }
        } else {
          if (this.param.updateTime) {
            return CommonUtils.dataToStr(this.param.updateTime)
          } else {
            return this.noData
          }
        }
      } else {
        return this.noData
      }
    }
  },
  mounted() {
    // this.setParamInner();
  }
}
</script>

<style scoped>

.user-time {
  font-size: 10px;
  text-align: right;
  margin: 4px 0;
}
</style>